/**
 * Created by lenovo on 2016/4/12.
 */
public class ComplexNumber {
    public double m_dRealPart;
    public double m_dImaginPart;

    public ComplexNumber(){
        this.m_dImaginPart=0;
        this.m_dRealPart=0;
    }

    public ComplexNumber(double r,double I){
        this.m_dRealPart=r;
        this.m_dImaginPart=I;
    }

    public double GetRealPart(){
        return this.m_dRealPart;
    }

    public double GetImaginaryPart(){
        return this.m_dImaginPart;
    }

    public void SetRealPart(double d){
        this.m_dRealPart=d;
    }

    public void SetImaginaryPart(double d){
        this.m_dImaginPart=d;
    }

    public ComplexNumber ComplexAdd1(ComplexNumber c){
        this.m_dRealPart=this.m_dRealPart+c.m_dRealPart;
        this.m_dImaginPart=this.m_dImaginPart+c.m_dImaginPart;
        return this;
    }

    public ComplexNumber ComplexAdd2(double c){
        this.m_dRealPart=this.m_dRealPart+c;
        return this;
    }

    public ComplexNumber ComplexMinus1(ComplexNumber c) {
        this.m_dRealPart = this.m_dRealPart - c.m_dRealPart;
        this.m_dImaginPart = this.m_dImaginPart - c.m_dImaginPart;
        return this;
    }

    public ComplexNumber ComplexMinus2(double c){
        this.m_dRealPart=this.m_dRealPart-c;
        return this;
    }

    public ComplexNumber ComplexMulti1(ComplexNumber c){
        double a=this.m_dImaginPart;
        double b=this.m_dRealPart;

        this.m_dRealPart=b*c.m_dRealPart-(a*c.m_dImaginPart);
        this.m_dImaginPart=b*c.m_dImaginPart+a*c.m_dRealPart;
        return this;
    }

    public ComplexNumber ComplexMulti2(double c){
        double a=this.m_dImaginPart;
        double b=this.m_dRealPart;

        this.m_dRealPart=this.m_dRealPart*c;
        this.m_dImaginPart=this.m_dImaginPart*c;
        return this;
    }

    public String toString(){
        return this.m_dRealPart+"+"+this.m_dImaginPart+"i";
    }

//	public static void main(String[] args){}
}
